define([
  'jquery',
  'views/Form',
  'hbs!template/residences/residence-form',
  'bootstrap_tooltip',
  'bootstrap_popover'
], function($, Form, template){
  var ResidenceForm = Form.extend({
    events: {
      "click button[name=save]":   "save",
      "click button[name=cancel]": "cancel"
    },
    
    initialize: function() {
      this.template = template;
      this.model.bind("change", this.render, this);
    },
    
    renderContain: function() {
    	this.$('[rel="popover"]').popover();
    },
    
    save: function() {
      var object = this.getObjectFromForm(this.$("form"));
      this.model.save(object);
    },

    cancel: function() {
      console.log("ResidenceForm canceling!!!!");
      this.back();
    }
  });

  return ResidenceForm;
});